﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SunrayEngine.Maps
{
    public class MapManager : DrawableGameComponent
    {
        #region fields
        private SpriteBatch spriteBatch;
        private Dictionary<string, Map> maps;
        private Map activeMap;
        #endregion

        public MapManager(Game game, SpriteBatch spriteBatch)
            : base(game)
        {
            this.spriteBatch = spriteBatch;
            activeMap = null;
            maps = new Dictionary<string, Map>();
        }

        public void LoadMap(string path, string name)
        {
            maps.Add(name, Map.Load(path, Game.GraphicsDevice.Viewport.Bounds));
        }

        /// <summary>
        /// Debugging purpose
        /// </summary>
        /// <param name="map"></param>
        public void SetActiveMap(string map)
        {
            activeMap = maps[map];
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            if (activeMap != null)
                activeMap.Draw(spriteBatch);
        }
    }
}
